<template>
	<view class="pages">

		<view class="items" style="margin-top: 64rpx;">
			<view class="itemsLeft">
				<u--input :placeholder="$t('newAddress.newAddress1tips')" border="none" v-model="FormData.address"
					style="width: 500rpx;border: none;"></u--input>
			</view>
			<view class="itemsRight" @click="Addressclear">
				<!-- <u-icon name="close-circle" v-if="FormData.address"></u-icon> -->
				<image v-if="FormData.address" src="../../static/qingchu.png" mode=""
					style="width: 35rpx;height: 35rpx;right: 0rpx;margin-top: 3rpx;"> </image>
			</view>
		</view>

		<view class="items" style="margin-top: 20rpx;">
			<view class="itemsLeft">
				<u--input :placeholder="$t('newAddress.newAddress2tips')" border="none" v-model="FormData.address2"
					style="width: 500rpx;border: none;"></u--input>
			</view>
			<view class="itemsRight" @click="Address2clear">
				<!-- <u-icon name="close-circle" v-if="FormData.address2"></u-icon> -->
				<image v-if="FormData.address2" src="../../static/qingchu.png" mode=""
					style="width: 35rpx;height: 35rpx;right: 0rpx;margin-top: 3rpx;"> </image>
			</view>
		</view>

		<u-button type="primary"  :text="$t('newAddress.Confirm')"
			:customStyle="{width:'640rpx',height:'80rpx',backgroundColor:'#273562',color:'#fff',margin:'60px auto 0rpx',fontWeight:'700',border:'none',borderRadius: '16rpx'}"
			@click="submit"></u-button>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				newUrl:1,//0为新接口1为老接口
				FormData: {
					...JSON.parse(uni.getStorageSync('user'))
				},
			}
		},
		onShow() {
		},
		methods: {
			Addressclear() {
				this.FormData.address = ''
			},
			Address2clear() {
				this.FormData.address2 = ''
			},
			// 提交
			submit() {
				if (!this.FormData.address) {
					this.$ToastFail(this.$t('newAddress.newAddress1tips'))
					return
				}
				if (!this.FormData.address2) {
					this.$ToastFail(this.$t('newAddress.newAddress2tips'))
					return
				}
				uni.showLoading({
					title: this.$t('Laoding'),
				})
				this.$post(`/backend/user/editUserInfo`, this.FormData,this.newUrl).then(res => {
					if (res.status) {
						this.$ToastOk(`${res.data.msg}`)
						setTimeout(() => {
							uni.switchTab({
								url: './Profile'
							})
						}, 1000)
					} else {
						this.$ToastFail(`${res.message}`)
					}
				})
			}
		}
	}
</script>

<style>
	.pages {
		width: 100%;
		height: 100vh;
		overflow-y: auto;
		/* padding: 0 26rpx; */
		box-sizing: border-box;
		background-color: #F0F0F0;
		padding-bottom: 60rpx;
	}

	.items {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		height: 104rpx;
		background-color: #fff;
		padding: 0 20rpx;
		box-sizing: border-box;
	}

	.itemsLeft {
		display: flex;
		align-items: center;
		justify-content: flex-start;
		/* background-color: red; */
		width: 500rpx;
	}

	.itemsRight {
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}

	.itemsRight span {
		font-family: Montserrat;
		font-size: 32rpx;
		font-weight: 400;
		letter-spacing: 0.20000000298023224px;
		text-align: right;
		color: #808080;
		margin-right: 10rpx;
	}

	.items span {
		font-family: Montserrat;
		font-size: 32rpx;
		font-weight: 400;
		letter-spacing: 0.20000000298023224px;
		text-align: left;
		margin-left: 10rpx;

	}
</style>